Flask Tutorial / Digital Ocean

by: pmandl, 9 years ago


Hi Harrison,

I set up a server on digitalocean following your tutorial. When I try to call /dashboard, I get an internal Server Error.
You may also notice in the error log below, that my venv runs Python 2.7 ??
Can pease point me to s solution?
Thanks,
Peter

[Thu Feb 18 06:25:03.580833 2016] [mpm_event:notice] [pid 30689:tid 140694327183232] AH00493: SIGUSR1 received.  Doing graceful restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
[Thu Feb 18 06:25:03.655366 2016] [mpm_event:notice] [pid 30689:tid 140694327183232] AH00489: Apache/2.4.12 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.10 configured -- resuming normal operations
[Thu Feb 18 06:25:03.655402 2016] [core:notice] [pid 30689:tid 140694327183232] AH00094: Command line: '/usr/sbin/apache2'
[Thu Feb 18 07:39:19.700783 2016] [wsgi:error] [pid 7468:tid 140694102456064] ERROR:FlaskApp:Exception on /dashboard/ [GET]
[Thu Feb 18 07:39:19.700852 2016] [wsgi:error] [pid 7468:tid 140694102456064] Traceback (most recent call last):
[Thu Feb 18 07:39:19.700858 2016] [wsgi:error] [pid 7468:tid 140694102456064]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
[Thu Feb 18 07:39:19.700885 2016] [wsgi:error] [pid 7468:tid 140694102456064]     response = self.full_dispatch_request()
[Thu Feb 18 07:39:19.700889 2016] [wsgi:error] [pid 7468:tid 140694102456064]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
[Thu Feb 18 07:39:19.700892 2016] [wsgi:error] [pid 7468:tid 140694102456064]     rv = self.handle_user_exception(e)
[Thu Feb 18 07:39:19.700895 2016] [wsgi:error] [pid 7468:tid 140694102456064]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
[Thu Feb 18 07:39:19.700898 2016] [wsgi:error] [pid 7468:tid 140694102456064]     reraise(exc_type, exc_value, tb)
[Thu Feb 18 07:39:19.700901 2016] [wsgi:error] [pid 7468:tid 140694102456064]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
[Thu Feb 18 07:39:19.700904 2016] [wsgi:error] [pid 7468:tid 140694102456064]     rv = self.dispatch_request()
[Thu Feb 18 07:39:19.700906 2016] [wsgi:error] [pid 7468:tid 140694102456064]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
[Thu Feb 18 07:39:19.700909 2016] [wsgi:error] [pid 7468:tid 140694102456064]     return self.view_functions[rule.endpoint](**req.view_args)
[Thu Feb 18 07:39:19.700912 2016] [wsgi:error] [pid 7468:tid 140694102456064]   File "/var/www/FlaskApp/FlaskApp/__init__.py", line 11, in dashboard
[Thu Feb 18 07:39:19.700915 2016] [wsgi:error] [pid 7468:tid 140694102456064]     return render_template("dashboard.html")
[Thu Feb 18 07:39:19.700918 2016] [wsgi:error] [pid 7468:tid 140694102456064]   File "/usr/local/lib/python2.7/dist-packages/flask/templating.py", line 128, in render_template
[Thu Feb 18 07:39:19.700921 2016] [wsgi:error] [pid 7468:tid 140694102456064]     context, ctx.app)
[Thu Feb 18 07:39:19.700923 2016] [wsgi:error] [pid 7468:tid 140694102456064]   File "/usr/local/lib/python2.7/dist-packages/flask/templating.py", line 110, in _render
[Thu Feb 18 07:39:19.700926 2016] [wsgi:error] [pid 7468:tid 140694102456064]     rv = template.render(context)
[Thu Feb 18 07:39:19.700929 2016] [wsgi:error] [pid 7468:tid 140694102456064]   File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
[Thu Feb 18 07:39:19.700932 2016] [wsgi:error] [pid 7468:tid 140694102456064]     return self.environment.handle_exception(exc_info, True)
[Thu Feb 18 07:39:19.700934 2016] [wsgi:error] [pid 7468:tid 140694102456064]   File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
[Thu Feb 18 07:39:19.700937 2016] [wsgi:error] [pid 7468:tid 140694102456064]     reraise(exc_type, exc_value, tb)
[Thu Feb 18 07:39:19.700940 2016] [wsgi:error] [pid 7468:tid 140694102456064]   File "/var/www/FlaskApp/FlaskApp/templates/dashboard.html", line 1, in top-level template code
[Thu Feb 18 07:39:19.700943 2016] [wsgi:error] [pid 7468:tid 140694102456064]     {% extends "header.html" %}
[Thu Feb 18 07:39:19.700945 2016] [wsgi:error] [pid 7468:tid 140694102456064]   File "/usr/local/lib/python2.7/dist-packages/flask/templating.py", line 60, in get_source
[Thu Feb 18 07:39:19.700948 2016] [wsgi:error] [pid 7468:tid 140694102456064]     return loader.get_source(environment, local_name)
[Thu Feb 18 07:39:19.700951 2016] [wsgi:error] [pid 7468:tid 140694102456064]   File "/usr/local/lib/python2.7/dist-packages/jinja2/loaders.py", line 175, in get_source
[Thu Feb 18 07:39:19.700954 2016] [wsgi:error] [pid 7468:tid 140694102456064]     contents = f.read().decode(self.encoding)
[Thu Feb 18 07:39:19.700956 2016] [wsgi:error] [pid 7468:tid 140694102456064]   File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
[Thu Feb 18 07:39:19.700959 2016] [wsgi:error] [pid 7468:tid 140694102456064]     return codecs.utf_8_decode(input, errors, True)
[Thu Feb 18 07:39:19.700962 2016] [wsgi:error] [pid 7468:tid 140694102456064] UnicodeDecodeError: 'utf8' codec can't decode byte 0xd7 in position 1666: invalid continuation byte




You must be logged in to post. Please login or register an account.



Could be a variety of errors. First step is to run the __init__.py file manually and see if you get any errors there. Next is to encase the function that returns a page in try/except if the 500 is not site-wide, which will help you get local errors as well as html/jinja issues.

-Harrison 9 years ago

You must be logged in to post. Please login or register an account.